﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;

namespace Perpus
{
    public partial class admin_MenuAwal : Form
    {
        public admin_MenuAwal()
        {
            InitializeComponent();
            
        }

        public string _labelWelcome
        {
            get { return label3.Text; }
            set { label3.Text = value; }
        }

        string koneksi = MappingDatabase.koneksi;

        private ISessionFactory CreateSessionFactory()
        {
            return Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(koneksi))
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<AnggotaMap>())
                .BuildSessionFactory();
        }

        private void admin_MenuAwal_Load(object sender, EventArgs e)
        {
            label3.Text = _labelWelcome;
            //var factory = CreateSessionFactory();

            //int idPeg = Convert.ToInt32(label2.Text);

            //using (var session = factory.OpenSession())
            //{

            //    var userPeg = from c in session.Query<Pegawai>()
            //                  where c.id_pegawai == idPeg
            //                  select c.nama_pegawai;
            //    string _lbl = userPeg.First();
            //    label3.Text = _lbl;
            //}
        }

        private void button1_Click(object sender, EventArgs e)
        {
            TampilanBuku book_view = new TampilanBuku();
            book_view.Show();
            this.Hide();
        }

        private const int CP_NOCLOSE_BUTTON = 0x200;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams myCp = base.CreateParams;
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
                return myCp;
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            LoginForm log = new LoginForm();
            MessageBox.Show("Anda Telah Logout");
            log.Show();
            this.Hide();
           // Application.Exit();
            
        }

        private void button4_Click(object sender, EventArgs e)
        {
            TampilanAnggota anggota = new TampilanAnggota();
            anggota.Show();
            this.Hide();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            admin_dataPegawai peg = new admin_dataPegawai();
            peg.Show();
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            PinjamBuku borrow = new PinjamBuku();
            borrow.Show();
            this.Hide();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            KembaliBuku back = new KembaliBuku();
            back.Show();
            this.Hide();
        }

    }
}
